/*Declaring needed libraries for that task*/
import java.util.Scanner;
public class PrimeNumbers
{
	public static void main(String[] args)
	{
		/*Creating Scanner and reading inout data from the user:*/
      Scanner input = new Scanner(System.in);
		System.out.print("Please enter any integer number you would like to: ");
		String number = input.next();
		int checknumber=0;
   		/*try-catch construction in case if entered data is not valid. TO avoid throwing an error*/
         try 
   		{
   			checknumber = Integer.parseInt(number);
   		}
   			catch (NumberFormatException e) 
   		{
       		System.err.println("Sorry but the argument must be an integer." +
                              " Please re-run the program and provide integer number.");
       		System.exit(1);
   		}
   		int status=0;
         System.out.println("All prime number in a range between 2 and " + checknumber + ") are as follow:");

         /*Main logic. Using loop in a loop to find all prime numbers in a range 2..<entered by the user>*/
   		for (int i=2; i<checknumber; i++)
   		{
   			for (int ii=2; ii<i; ii++)
   			if ((i%ii)!=0)
   			{
   				status++;
   			} 
   			if (status==(i-2))
   				System.out.println(i);
   			status=0;
   		}
	}
}